<template>
  <div align="center">
    <el-button type="warning"  @click="changUserId"
               size="medium"
               style="margin-left: 800px;"
               plain>切换用户</el-button>当前用户：{{this.queryForm.userId}}
    <el-table
        :data="tableData"
        stripe
        style="width: 100%">
      <el-table-column
          prop="entrustTime"
          label="委托时间"
          width="180">
      </el-table-column>
      <el-table-column
          prop="entrustStockCode"
          label="股票代码"
          width="180">
      </el-table-column>
      <el-table-column
          prop="entrustBankName"
          width="180"
          label="股票名称">
      </el-table-column>
      <el-table-column
          prop="entrustPrice"
          label="委托价格"
          width="180">
      </el-table-column>
      <el-table-column
          prop="entrustNum"
          width="180"
          label="委托数量">
      </el-table-column>
      <el-table-column
          prop="entrustDirection"
          label="方向"
          width="180">
      </el-table-column>
      <el-table-column
          prop="entrustStatus"
          width="180"
          label="状态">
      </el-table-column>
    </el-table>
    <!--       分页-->
    <el-pagination
        background
        :page-size="this.queryForm.pageSize"
        :current-page="this.queryForm.pageSize"
        @current-change="toNewPage"
        layout="prev, pager, next"
        :total="total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: "HistoryEntrustView.vue",
  data(){
    return{
      tableData:[],
      queryForm:{
        pageNum:1,
        pageSize:3,
        userId:1,
      },
      total:0,
    }
  },
  created() {
    this.getEntrustList();
  },
  methods:{
    //切换用户
    changUserId(){
      if(this.queryForm.userId==1){
        this.queryForm.userId=4;
      }else if(this.queryForm.userId==4){
        this.queryForm.userId=1;
      }
      console.log(this.queryForm.userId);
      this.getEntrustList();
    },
    toNewPage(newPage){
      this.queryForm.pageNum=newPage;
      this.getEntrustList();
    },
    getEntrustList(){
      this.axios.post("http://localhost:8182/stock/getHistoryEntrustList",this.queryForm).then(r=>{
        this.tableData=r.data.data.list;
        this.total=r.data.data.total;
      })
    },
  }
}
</script>

<style scoped>

</style>